package com.yntsoft.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.yntsoft.entity.Permission;
import com.yntsoft.entity.ShiroUser;
import com.yntsoft.service.PermissionService;

/**
 * 登陆控制层
 * @author Tony
 *
 */
@Controller
public class FirstController {

	@Autowired
	private PermissionService permissionService;
	
	/**
	 * 登陆控制层
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "first")
	public String login(HttpServletRequest request,Model model)throws Exception{
		Subject subject = SecurityUtils.getSubject();
		ShiroUser shiroUser = (ShiroUser)subject.getPrincipal();
		List<Permission> menus = permissionService.queryMenu(shiroUser.getUserId(),Permission.TYPE_MENU,null);
		model.addAttribute("menus", menus);
		return "index/index";
	}
}
